<?php
/**
 *
 * @package 
 * @since 1.0
 */
 
	//发送邮件
	function sendemail($address,$sendname,$revname,$content,$ss){
		import('@.ORG.phpmailer');
		$mail = new phpmailer();
		$mail->IsSMTP(); // send via SMTP phperz~com
		$mail->Host = "smtp.qq.com"; // SMTP servers
		$mail->SMTPAuth = true; // turn on SMTP authentication
		$mail->Username = "1824383821"; // SMTP username 注意：普通邮件认证不需要加 @域名?
		$mail->Password = "dingding123"; // SMTP password
		$mail->From = "1824383821@qq.com";
		$mail->CharSet='UTF-8';
		$mail->FromName = $sendname;
		$mail->AddAddress($address, $revname);
		$mail->Subject = $ss;//邮件标题
		$mail->Body = $content;
		//$mail->AltBody = "This is the body in plain text for non-HTML mail clients"; //附加信息，可以省略
		if(!$mail->Send())
		{
			echo "邮件发送失败. <p>";
			echo "错误原因: " . $mail->ErrorInfo;
			exit;
		}
		//echo "邮件发送成功";
	}

/**
 *
 +--------------------------------------------------
 * 获取广告代码
 +--------------------------------------------------
 * @param $atype	广告名
 +--------------------------------------------------
 * @return string	广告代码
 +--------------------------------------------------
 */
function getad($title){
	assert ( is_string($title) );
	
	$data = M('advance')->where("title='".$title."'")->field('url,pic')->find();
	if($data){
		$html = "<a href='".$data['url']."'><img src='".$data['pic']."' /></a>";
	}else{
	    $html = NULL;
	}

	return $html;
}

/**
 *
 +--------------------------------------------------
 * 获取banner图代码
 +--------------------------------------------------
 * @author wangcheng	<360954149@qq.com>
 +--------------------------------------------------
 * @param $title	广告名
 +--------------------------------------------------
 * @return string	广告代码
 +--------------------------------------------------
 */
function getbanner($title){
	assert ( is_string($title) );
	
	$data = M('banner')->where("location='".$title."'")->field('url,pic')->find();
	if($data){
	    if(empty($data['url'])){
			$html = "<img src='".$data['pic']."' />";
		}else{
			$html = "<a href='".$data['url']."'><img src='".$data['pic']."' /></a>";
		}

	}else{
	    $html = NULL;
	}
	return $html;
}


